<template>
  <div>
    <div class="empty"></div>
    <div class="top">
      <div class="left top-left">电商后台管理</div>
      <div class="right top-right">
        <div class="head-time">
          {{ time }}
        </div>
        <div>
          <i class="el-icon-user-solid"></i>
        </div>
        <div class="iconRight">
          <p>欢迎您！</p>
          <p>超级管理员</p>
        </div>
        <div class="clear"></div>
      </div>
      <div class="clear"></div>
    </div>
    <div class="left leftMenu">
      <el-menu
        default-active="2"
        class="el-menu-vertical-demo leftMenu"
        background-color="#545c64"
        text-color="#fff"
        active-text-color="#ffd04b"
        router
      >
        <template v-for="(item, index) in menuList">
          <el-menu-item
            v-if="!item.children && index < 2"
            :key="index"
            :index="item.path"
          >
            <i :class="item.icon"></i>

            <span slot="title">{{ item.name }}</span>
          </el-menu-item>
        </template>
        <template v-for="(item, index) in menuList">
          <el-submenu v-if="item.children" :key="index" :index="index + ''">
            <template slot="title">
              <i :class="item.icon"></i>
              <span>{{ item.name }} </span>
            </template>
            <el-menu-item-group>
              <el-menu-item
                v-for="(itemChild, indexChild) in item.children"
                :key="indexChild"
                :index="itemChild.path"
                >{{ itemChild.name }}</el-menu-item
              >
            </el-menu-item-group>
          </el-submenu>
        </template>
        <template v-for="(item, index) in menuList">
          <el-menu-item
            v-if="!item.children && index > 2"
            :key="index"
            :index="item.path"
          >
            <i :class="item.icon"></i>
            <span slot="title">{{ item.name }}</span>
          </el-menu-item>
        </template>
      </el-menu>
    </div>
    <div class="right rightBox">
      <router-view></router-view>
    </div>
    <div class="clear"></div>
  </div>
</template>
<script>
export default {
  name: "home",
  data() {
    return {
      menuList: [
        {
          path: "/systemHome",
          name: "系统首页",
          icon: "el-icon-house",
        },
        {
          path: "/commodityManagement",
          name: "商品管理",
          icon: "el-icon-box",
        },
        {
          name: "内容管理",
          icon: "el-icon-notebook-2",
          children: [
            {
              path: "/contentManagement/documentManagement",
              name: "文案管理",
            },
            {
              path: "/contentManagement/managementActivities",
              name: "活动管理",
            },
          ],
        },
        {
          path: "/userManagement",
          name: "用户管理",
          icon: "el-icon-user",
        },
        {
          path: "/orderManagement",
          name: "订单管理",
          icon: "el-icon-tickets",
        },
        {
          path: "/inventoryManagement",
          name: "库存管理",
          icon: "el-icon-box",
        },
        {
          path: "/mycom",
          name: "输入框式表格",
          icon: "el-icon-box",
        },
        {
          path: "/MultistageHeader",
          name: "多级表头",
          icon: "el-icon-box",
        },
      ],
      time: "",
    };
  },
  methods: {
    double(value) {
      return value < 10 ? "0" + value : value;
    },
  },
  mounted() {
    let _self = this;
    setInterval(() => {
      let now = new Date();
      let year = now.getFullYear();
      let month = now.getMonth() + 1;
      let day = now.getDate();
      let hour = now.getHours();
      let minutes = now.getMinutes();
      let second = now.getSeconds();
      _self.time =
        year +
        "年" +
        (month < 10 ? "0" + month : month) +
        "月" +
        (day < 10 ? "0" + day : day) +
        "日" +
        " " +
        (hour < 10 ? "0" + hour : hour) +
        ":" +
        (minutes < 10 ? "0" + minutes : minutes) +
        ":" +
        (second < 10 ? "0" + second : second);
    }, 1000);
  },
};
</script>
<style>
.left {
  float: left;
}
.right {
  float: right;
}
.clear {
  clear: both;
  height: 0;
}
.leftMenu {
  position: fixed;
  top: 40px;
  height: 100%;
  background-color: #545c64;
  width: 200px;
  box-sizing: border-box;
}
.rightBox {
  width: calc(100% - 200px);
}
.top {
  width: 100%;
  height: 40px;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 99;
}
.top-left {
  width: 200px;
  background-color: #50565c;
  line-height: 40px;
  font-size: 20px;
  color: #fff;
  text-align: center;
}
.top-right {
  width: calc(100% - 200px);
  height: 40px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  border-bottom: 1px solid #50565c;
  box-sizing: border-box;
  background-color: #fff;
}
.head-time {
  margin: 0 40px;
}
.iconRight {
  margin: 0 10px;
}
.empty {
  height: 40px;
}
</style>
